package jin.chen.common;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import redis.clients.jedis.JedisPoolConfig;

/**
 * redis配置类
 */
//@Configuration
public class RedisConfig {
//    private RedisConnectionFactory connectionFactory = null;
//
//    @Bean
//    public RedisConnectionFactory initRedisConnectionFactory(){
//        if(this.connectionFactory != null){
//            return this.connectionFactory;
//        }
//        JedisPoolConfig poolConfig = new JedisPoolConfig();
//        //最大空闲数
//        poolConfig.setMaxIdle(30);
//        //最大连接数
//        poolConfig.setMaxTotal(50);
//        //罪罚等待毫秒数,2秒
//        poolConfig.setMaxWaitMillis(2000);
//        //创建jedis连接工厂
//        JedisConnectionFactory connectionFactory = new JedisConnectionFactory(poolConfig);
//        //获取单机redis配置
//        RedisStandaloneConfiguration rscfg = connectionFactory.getStandaloneConfiguration();
//        connectionFactory.setHostName("localhost");//43.234.207.183
//        connectionFactory.setPort(6379);
//        connectionFactory.setPassword("");//adgjmptw258
//        this.connectionFactory = connectionFactory;
//        return connectionFactory;
//
//    }
//
//    @Bean
//    public RedisTemplate<Object, Object> initRedisTemplate(){
//        RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
//        redisTemplate.setConnectionFactory(initRedisConnectionFactory());
//        return redisTemplate;
//    }
}
